<?php
namespace app\service;
use think\Db;
class packageService{





    //添加月租车信息
    public function packageAdd($data){
        return Db::name('car_package')->insert($data);
    }
    //查询指定ID月租车信息
    public function packageId($id){
        return Db::name('car_package')->where('id',$id)->find();
    }
    //修改指定ID月租车信息
    public function packageEdit($data){
        return Db::name('car_package')->update($data);
    }
    //删除指定ID月租车信息
    public function packageDel($id){
        return Db::name('car_package')->delete($id);
    }


    //通过Excel插入数据
    public function packageExcelAdd($data){
        return Db::name('package')->insertGetId($data);
    }
    //--------------------------------------------------------------------------------------------------
    //根据条件查找地库车信息
    public function libraryList($whe){
        return Db::name('library')->where($whe)->order('id desc')->paginate(100);
    }
    //多条件查询查找区域数据
    public function libraryWhereList($community_id,$page,$where){
        return Db::name('library')->where('community_id', 'in', $community_id)->where($where)->order('out_time')->paginate(100, false, [
            'page'  =>  $page,
            'query' =>  $where
        ]);
    }
    //查询数据地库车条数
    public function libraryWhereListNumber($community_id,$where){
        return Db::name('library')->where('community_id', 'in', $community_id)->where($where)->select();
    }
    //查询地库号是否重复
    public function garageId($out_parking_id,$garage_id){
        return Db::name('library')->where('garage_id',$garage_id)->where('out_parking_id',$out_parking_id)->find();
    }
    //添加地库车信息
    public function libraryAdd($data){
        return Db::name('library')->insert($data);
    }
    //查询指定ID地库车信息
    public function libraryId($id){
        return Db::name('library')->where('id',$id)->find();
    }
    //修改指定ID地库车信息
    public function libraryEdit($data){
        return Db::name('library')->update($data);
    }
    //删除指定ID地库车信息
    public function libraryDel($id){
        return Db::name('library')->delete($id);
    }
    //修改指定ID地库车状态
    public function libraryStatus($id,$status){
        return Db::name('library')->where('id' , $id)->setField('status' , $status);
    }
    //-----------------------------------------------------------------------------------------------------
    //根据停车场名称查询停车场ID
    public function parkingNameId($parking_name){
        return Db::name('parkinglotinfo')->where('parking_name',$parking_name)->find();
    }
    //通过Excel插入数据
    public function libraryExcelAdd($data){
        return Db::name('library')->insertGetId($data);
    }
}